#{extends 'adminm/frame.html' /}

#{set 'moreScripts'}
<script src="@{'/public/javascripts/jquery-ui-1.8.10.custom.min.js'}" type="text/javascript" charset="utf-8"></script>
<script src="@{'/public/pager/jquery.pager.js'}" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript" src="@{'/public/uploadify/swfobject.js'}"></script>
<script type="text/javascript" src="@{'/public/uploadify/jquery.uploadify.v2.1.4.min.js'}"></script>
#{/set}
#{set 'moreStyles'}
<link rel="stylesheet" type="text/css" media="screen" href="@{'/public/stylesheets/table.scss'}" />

<link href="@{'/public/uploadify/uploadify.css'}" type="text/css" rel="stylesheet" />
#{/set}
#{set 'activeItem'}1#{/set}

<div class="navigationBar">
	<table>
		<tr>
			<td><img src="@{'/public/images/navigationHouse.gif'}"></td>
			<td><strong>当前位置：</strong></td>
			<td>
				<a href="/admin">首页</a>
				>>
				<a href="/admin/users">用户管理</a>
				>>
				<font class="current">修改管理</font>
			</td>
		</tr>
	</table>
</div>
<script language="javascript">
$(function(){
	$("#birthday").datepicker({
		changeMonth: true,
		changeYear: true,
		showButtonPanel: true,
		dateFormat: 'yy-mm-dd'
	});
	/* uploadify2 */
	$('#image_upload').uploadify({
	    uploader	: '@{'/public/uploadify/uploadify.swf'}',
	    script		: '@{Attachments.create_uploadify}',
	    cancelImg	: '@{'/public/uploadify/cancel.png'}',
	    fileDataName: 'file',
	    fileExt     : '*.jpg;*.gif;*.png',
		fileDesc    : 'Image Files (.JPG, .GIF, .PNG)',
		sizeLimit   : 1024000,
    	auto		: true,
    	onComplete	: function(event, ID, fileObj, response, data){
    		//显示附件
    		var getAttachmentAction = #{jsAction @Attachments.show(':id') /}
    		$("#image").attr('src', getAttachmentAction({id: response}));
    		//将附件ID添加到form里面
    		$("#image_upload").val(response);
    	}
	});
});
function doSubmit() {
	$("#form1").submit();
}
function reset() {
	window.location.href="/admin/users/${user.id};edit";
}
</script>
<div id="errMsg" class="error">
	#{error 'errMsg'/}
</div>
<table class="table_edit">
	<thead>
		<tr>
			<th colspan="2">修改用户</th>
		</tr>
	</thead>
	<tbody>
		#{form @admin.users.update(), name:'form1', id:'form1'}
		<tr>
			<td class="left" width="40%">ID：</td>
			<td>
				<input type="text" maxlength="30" disabled value="${user.id}">
				<input type="hidden" name='user.id' maxlength="30" value="${user.id}">
				<font class="require">*</font>&nbsp;
				<span class="error">#{error 'user.id' /}</span>
			</td>
		</tr>
		<tr>
			<td class="left" width="40%">账号：</td>
			<td>
				<input type="text" maxlength="30" disabled value="${user.username}">
				<input type="hidden" name='user.username' maxlength="30" value="${user.username}">
				<font class="require">*</font>&nbsp;
				<span class="error">#{error 'user.username' /}</span>
			</td>
		</tr>
		<tr>
			<td class="left" width="40%">真名：</td>
			<td>
				<input type="text" name='user.realname' maxlength="30" value="${user.realname}">
				<font class="require">*</font>&nbsp;
				<span class="error">#{error 'user.realname' /}</span>
			</td>
		</tr>
		<tr>
			<td class="left" width="40%">密码：</td>
			<td>
				<input type="text" name='user.password' maxlength="30" value="${user.password}">
				<font class="require">*</font>&nbsp;
				<span class="error">#{error 'user.password' /}</span>
				<br>
				(长度为8~20)
			</td>
		</tr>
		<tr>
			<td class="left" width="40%">身份证：</td>
			<td>
				#{if user.idphoto}
					<img id="image" src="@{Attachments.show(user.idphoto.id)}"/>(大小1M以下)
					<p><input id="image_upload" type="text" name="user.idphoto.id" value="${user.idphoto.id}"/></p>
				#{/if}
				#{else}
					<img id="image" src="@{'/public/images/image-placeholder.png'}"/>(大小1M以下)
		    		<p><input id="image_upload" type="text" name="user.idphoto.id" /></p>
				#{/else}
		    	<font class="important_1_1">*</font>&nbsp;<br>
				<span class="error">#{error 'user.idphoto' /}</span>
			</td>
		</tr>
		<tr>
			<td class="left" width="40%">安全问题：</td>
			<td>
				<input type="text" name='user.question' maxlength="30" value="${user.question}">
				<font class="require">*</font>&nbsp;
				<span class="error">#{error 'user.question' /}</span>
			</td>
		</tr>
		<tr>
			<td class="left" width="40%">答案：</td>
			<td>
				<input type="text" name='user.answer' maxlength="30" value="${user.answer}">
				<font class="require">*</font>&nbsp;
				<span class="error">#{error 'user.answer' /}</span>
			</td>
		</tr>
		<tr>
			<td class="left" width="40%">性别：</td>
			<td>
				<select name='user.sex'>
					<option value="">保密</option>
					<option value="M" #{if user.sex == 'M'}selected#{/if}>男</option>
					<option value="F" #{if user.sex == 'F'}selected#{/if}>女</option>
				</select>
				<span class="error">#{error 'user.sex' /}</span>
			</td>
		</tr>
		<tr>
			<td class="left" width="40%">生日：</td>
			<td>
				<input type="text" id="birthday" name='user.birthday' maxlength="30" readonly="readonly" value="${user.birthday?.format('yyyy-MM-dd')}">
				<span class="error">#{error 'user.birthday' /}</span>
			</td>
		</tr>
		<tr>
			<td class="left" width="40%">居住城市：</td>
			<td>
				<input type="text" name='user.province' maxlength="30" size="8" value="${user.province}">省 
				<input type="text" name='user.city' maxlength="30" size="8" value="${user.city}">市
				<span class="error">#{error 'user.province' /}</span><span class="error">#{error 'user.city' /}</span>
			</td>
		</tr>
		<tr>
			<td class="left" width="40%">收货地址：</td>
			<td>
				<input type="text" name='user.deliveryAddress' maxlength="30" value="${user.deliveryAddress}">
				<span class="error">#{error 'user.deliveryAddress' /}</span>
			</td>
		</tr>
		<tr>
			<td class="left" width="40%">邮编：</td>
			<td>
				<input type="text" name='user.zipcode' maxlength="30" value="${user.zipcode}">
				<span class="error">#{error 'user.zipcode' /}</span>
			</td>
		</tr>
		<tr>
			<td class="left" width="40%">联系电话：</td>
			<td>
				<input type="text" name='user.phoneNo' maxlength="30" value="${user.phoneNo}">
				<span class="error">#{error 'user.phoneNo' /}</span>
			</td>
		</tr>
		<tr>
			<td class="left" width="40%">QQ：</td>
			<td>
				<input type="text" name='user.qqNo' maxlength="30" value="${user.qqNo}">
				<span class="error">#{error 'user.qqNo' /}</span>
			</td>
		</tr>
		<tr>
			<td class="left" width="40%">MSN：</td>
			<td>
				<input type="text" name='user.msnNo' maxlength="30" value="${user.msnNo}">
				<span class="error">#{error 'user.msnNo' /}</span>
			</td>
		</tr>
		<tr>
			<td class="left" width="40%">E-mail：</td>
			<td>
				<input type="text" name='user.email' maxlength="30" value="${user.email}">
				<font class="require">*</font>&nbsp;
				<span class="error">#{error 'user.email' /}</span>
			</td>
		</tr>
		#{/form}
	</tbody>
</table>
<br>
<center>
	<input type="button" value="保存" onClick="doSubmit()">&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="button" value="重置" onClick="reset()">
</center>